﻿using System.Drawing;

namespace DevExpress.CrmDemo.Win.Helpers
{
    public static class FormsExtensions
    {
        public static Bitmap CropBitmap(this Bitmap bitmap, Rectangle rectangle)
        {
            var croppedBitmap = new Bitmap(rectangle.Width, rectangle.Height);
            var graphics = Graphics.FromImage(croppedBitmap);
            graphics.DrawImage(bitmap, 0, 0, rectangle, GraphicsUnit.Pixel);
            return croppedBitmap;
        }

        public static Point Add(this Point point1, Point point2)
        {
            return Point.Add(point1, new Size(point2));
        }
    }
}
